// 验证账号是否可用
$('#username').change(function (e) {
    const username = $('#username').val();

    $.ajax({
        url: 'http://nocat.life:3021/user/username',
        type: 'POST',
        data: {
            username
        },
        success(res) {
            if (res.code !== 200) {
                e.target.nextElementSibling.innerText = "该账号已存在"
            } else {
                e.target.nextElementSibling.innerText = "";
            }
        }
    })

})

$('#registerBtn').click(function () {
    const username = $('#username').val();
    const password = $('#password').val();

    $.ajax({
        url: 'http://nocat.life:3021/user/register',
        type: 'POST',
        data: {
            username, password
        },
        success(res) {
            console.log(res);
            
        }
    })
})